import { BasicColumn, FormSchema } from '@/components/table';
import { getOrganizationList } from './role.api';
import { RenderType } from '@pkg/setting';

/**
 * 表格列定义
 */
export const columns: BasicColumn[] = [
  {
    title: '角色名称',
    dataIndex: 'roleName',
    width: 120,
  },
  {
    title: '角色编码',
    dataIndex: 'roleCode',
    width: 100,
  },
  {
    title: '查看所有地区',
    dataIndex: 'isLookAllData',
    width: 100,
    dictData: [
      { label: '否', value: 0, color: '#a6a9a6' },
      { label: '是', value: 1, color: '#09d550' },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '描述',
    dataIndex: 'roleDesc',
    width: 150,
  },
];

/**
 * 列表查询定义
 */
export const searchFormSchema: FormSchema[] = [
  {
    label: '机构名称',
    field: 'userName',
    component: 'ApiSelect',
    colProps: { span: 6 },
    componentProps: {
      api: getOrganizationList,
      labelField: 'organizationName',
      valueField: 'organizationId',
    },
  },
  {
    field: 'isLookAllData',
    label: '查看所有地区',
    component: 'Select',
    colProps: { span: 5 },
    componentProps: {
      options: [
        { label: '否', value: 0 },
        { label: '是', value: 1 },
      ],
    },
  },
  {
    label: '角色名称',
    field: 'roleName',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '角色编码',
    field: 'roleCode',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '角色编码',
    field: 'roleCode',
    component: 'Input',
    colProps: { span: 6 },
  },
];

/**
 * 表单定义
 */
export const formSchema: FormSchema[] = [
  {
    label: '',
    field: 'roleId',
    component: 'Input',
    show: false,
  },

  {
    label: '角色名称',
    field: 'roleName',
    required: true,
    component: 'Input',
  },
  {
    label: '角色编码',
    field: 'roleCode',
    component: 'Input',
    dynamicDisabled: ({ values }) => {
      return !!values.roleId;
    },
  },
  {
    label: '描述',
    field: 'roleDesc',
    component: 'InputTextArea',
  },
];
/**
 * 按钮定义
 */
export const actionFormSchema: FormSchema[] = [
  {
    label: '按钮名称',
    field: 'actionName',
    required: true,
    component: 'Input',
  },
  {
    label: '按钮编码',
    field: 'actionCode',
    required: true,
    component: 'Input'
  }
];
